﻿<!DOCTYPE html>
<html>
<head>
    <title>形象进度</title>
    <link href="/static/css/framework-font.css" rel="stylesheet"/>
    <script src="/static/js/jquery-2.1.1.js"></script>
    <script src="/static/bootstrap/js/bootstrap.js"></script>
    <link href="/static/bootstrap/css/bootstrap.min.css" rel="stylesheet"/>
    <script src="/static/js/jquery.cookie.js"></script>
    <link href="/static/css/framework-theme.css" rel="stylesheet"/>
    <script src="/static/js/framework-ui.js"></script>
    <script src="/static/js/framework-clientdata.js"></script>
    <script src="/static/js/yii.js"></script>

    <!--引用layui弹框插件-->
    <link href="/static/layui/css/layui.css" rel="stylesheet"/>
    <script src="/static/layui/layui.js"></script>
    <link href="/static/css/pattern/public.css" rel="stylesheet"/>

</head>
<body>
<style>
    .form-horizontal .control-label{display: inline-block;width:10%;
        text-align:justify!important;
        text-align-last:justify;/*解决IE的支持*/ }
    .title{font-size:16px;background-color:#fff;margin:15px 0px;line-height:45px;padding-left:20px;}
</style>
<div>
    <div class="new_serach" style="display: none">
        <form class="layui-form layui-col-md12 x-so" name="searchApply">
            <input type="hidden" name="typeId" value="{$typeId}">
            <input type="hidden" name="proId" value="{$proId}">
        </form>
    </div>


    <div class="new_main">

        <script type="text/html" id="applybarDemo">
            <div class="layui-btn-container">
                <a class="layui-btn-sm layui-btn layui-btn-danger"  lay-event="del">批量删除</a>
            </div>
        </script>


        <table class="layui-hide" id="apply" lay-filter="apply"></table>

        <script type="text/html" id="applyBtn">
            <button class="layui-btn layui-btn-sm" lay-event="detail">操作</button>
            <button class="layui-btn layui-btn-sm layui-btn-danger" lay-event="del">删除</button>
        </script>

    </div>
</div>
<script src="/static/js/index.js"></script>
<script src="/static/js/indextab.js"></script>
<script src="/static/js/pace.min.js"></script>
<!--弹框js-->
<script src="/static/js/yii.js"></script>
<script>
    layui.use(['form','jquery','layer','laydate','table'], function() { //独立版的layer无需执行这一句
        var $ = layui.jquery, layer = layui.layer;
        var form = layui.form;
        var laydate = layui.laydate;
        var table = layui.table //表格
        //日期范围
        laydate.render({
            elem: '#test6'
            , range: true
        });

        var url = "{:URL('project/AdvanceApply/index')}";
        //搜索操作
        $('.serach_btn').click(function () {
            var data=$("form[name='searchApply']").serializeArray();
            var dataVal = {};
            $.each(data, function(i, item){
                dataVal[item.name] = item.value;
            });
            var where = dataVal;
            search(table,url,where)
        });

        var data=$("form[name='searchApply']").serializeArray();
        var dataVal = {type:'list'};
        $.each(data, function(i, item){
            dataVal[item.name] = item.value;
        });
        var where = dataVal;
        //列表
        var title = "列表";
        var cols = [[
            {type: 'checkbox', fixed: 'left'}
            ,{field: 'id', title: 'ID',  sort: true, fixed: 'left',width:80, align:'center'}
            ,{field: 'reason', title: '延期原因', align:'center',event: 'viewReport', templet: "#reportID"}
            ,{field: 'delay', title: '延期时间',templet: '#typeTpl', unresize: true, align:'center'}
            ,{field: 'status', title: '审核状态', align:'center'}
            ,{field: 'addtime', title: '提交时间', align:'center',sort: true}
            ,{fixed: 'right',title: '操作', width:200, align:'center', toolbar: '#applyBtn'}
        ]];
        showlist(table, url, where, title, cols, [10, 20, 50], 10, '#apply', '#applybarDemo', 1, false);


        //监听行工具事件
        table.on('tool(apply)', function(obj) {
            var id = obj.data.id;
            switch (obj.event) {
                case 'detail':
                    var showUrl = "{:URL('project/AdvanceApply/detail')}?id="+id;
                    showView(showUrl,"详情");
                    break;
                case 'del':
                    layer.confirm('是否确定操作?', function(index){
                        let url="{:URL('project/AdvanceApply/del')}";
                        let where = {id:id};
                        publicDel(table,url,where,obj,index,1,"apply");
                    });
                    break;
            }
        });


        function showView(showUrl,type){
            layer.open({
                type: 2,
                skin: 'layui-layer-demo', //样式类名
                area: ['800px','440px'],            //宽度450px,高自适应
                anim: 2,
                shadeClose: false, //开启遮罩关闭,
                maxmin: true,
                title: type,
                content:showUrl,
                btn:['确定','取消'],
                yes: function (index,layero) {
                     var body = layer.getChildFrame('body', index);
                     var data = body.find("form[name='saveForm']").serializeArray();
                     $.ajax({
                         type: "post",
                         url: "{:URL('project/AdvanceApply/save')}",
                         data: data,
                         dataType: "json",
                         success: function (data) {
                             if(data.code!=0){
                                 layer.alert(data.msg);
                             }else{
                                 table.reload('apply')
                                 layer.close(index);
                             }
                         }
                     });

                },
            });
        }


        //头工具栏事件
        table.on('toolbar(apply)', function(obj){
            var checkStatus = table.checkStatus(obj.config.id);
            switch(obj.event){
                case 'del':
                    var data = checkStatus.data;
                    var id=[];
                    for (var i = 0; i < data.length; i++) {
                        id[i] = data[i].id;
                    }
                    layer.confirm('是否确定操作?', function(index){
                        let url="{:URL('project/AdvanceApply/del')}";
                        let where = {id:id};
                        publicDel(table,url,where,obj,index,1,"apply");
                    });
                    break;
            };
        });

    });
</script>
</body>
</html>
